package com.hziee.mail.dao;

import com.hziee.mail.model.EvaluateInfoEntity;
import com.hziee.mail.model.OrderInfoEntity;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;
import java.util.Map;

/**
 * @author ZX
 */
public interface EvalRepository extends JpaRepository<EvaluateInfoEntity, Integer>, CrudRepository<EvaluateInfoEntity, Integer> {

    /**
     * 显示评论
     *
     * @param goodsId
     * @return
     */
    @Query(nativeQuery = true, value = "SELECT " +
            "evaluate_info.user_id, " +
            "evaluate_info.goods_id, " +
            "evaluate_info.ly, " +
            "evaluate_info.time, " +
            "user_info.user_real_name " +
            "FROM " +
            "evaluate_info " +
            "JOIN user_info on user_info.user_id = evaluate_info.user_id " +
            "WHERE evaluate_info.goods_id = :goodsId")
    List<Map> showEval(@Param("goodsId") String goodsId);
}
